package com.survey.project.research.service.impl;

import java.util.List;

import com.survey.common.utils.DateUtils;
import com.survey.project.research.domain.ConsumerAnswer;
import com.survey.project.research.mapper.ConsumerAnswerMapper;
import com.survey.project.research.service.IConsumerAnswerService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 用户答案Service业务层处理
 *
 * @author survey
 * @date 2021-05-26
 */
@RequiredArgsConstructor
@Service
public class ConsumerAnswerServiceImpl implements IConsumerAnswerService {

    private final ConsumerAnswerMapper consumerAnswerMapper;

    /**
     * 查询用户答案
     *
     * @param consumerAnswerId 用户答案ID
     * @return 用户答案
     */
    @Override
    public ConsumerAnswer selectConsumerAnswerById(Long consumerAnswerId) {
        return consumerAnswerMapper.selectConsumerAnswerById(consumerAnswerId);
    }

    /**
     * 查询用户答案列表
     *
     * @param consumerAnswer 用户答案
     * @return 用户答案
     */
    @Override
    public List<ConsumerAnswer> selectConsumerAnswerList(ConsumerAnswer consumerAnswer) {
        return consumerAnswerMapper.selectConsumerAnswerList(consumerAnswer);
    }

    /**
     * 新增用户答案
     *
     * @param consumerAnswer 用户答案
     * @return 结果
     */
    @Override
    public int insertConsumerAnswer(ConsumerAnswer consumerAnswer) {
        consumerAnswer.setCreateTime(DateUtils.getNowDate());
        return consumerAnswerMapper.insertConsumerAnswer(consumerAnswer);
    }

    /**
     * 修改用户答案
     *
     * @param consumerAnswer 用户答案
     * @return 结果
     */
    @Override
    public int updateConsumerAnswer(ConsumerAnswer consumerAnswer) {
        consumerAnswer.setUpdateTime(DateUtils.getNowDate());
        return consumerAnswerMapper.updateConsumerAnswer(consumerAnswer);
    }

    /**
     * 批量删除用户答案
     *
     * @param consumerAnswerIds 需要删除的用户答案ID
     * @return 结果
     */
    @Override
    public int deleteConsumerAnswerByIds(Long[] consumerAnswerIds) {
        return consumerAnswerMapper.deleteConsumerAnswerByIds(consumerAnswerIds);
    }

    /**
     * 删除用户答案信息
     *
     * @param consumerAnswerId 用户答案ID
     * @return 结果
     */
    @Override
    public int deleteConsumerAnswerById(Long consumerAnswerId) {
        return consumerAnswerMapper.deleteConsumerAnswerById(consumerAnswerId);
    }
}
